import { useIntersectionObserver } from '@vueuse/core'
import { ref } from 'vue'

export const lazyApi = callback => {
  const target = ref(null)
  const { stop } = useIntersectionObserver(
    target,
    ([{ isIntersecting }], observerElement) => {
      if(isIntersecting) {
        callback()
        stop()
      }
    }
  )
  return { target }
}
